package com.cdty.chess.controller;

import com.cdty.chess.model.BetInfo;
import com.cdty.chess.service.BetInfoService;
import com.cdty.chess.vo.BetInfoSticVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 下注
 */
@RestController
@RequestMapping("/api/v1/bet")
public class BetInfoController {


    @Autowired
    BetInfoService service;

    /**
     * 下注
     */
    @PostMapping("/addBetInfo")
    public String addBetInfo(@RequestBody BetInfo info){
        return service.addBetInfo(info);
    }

    /**
     * 查看今日记录
     */
    @GetMapping("/getBetInfo")
    public List<BetInfo> getBetInfo(@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime s_time,
                                    @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime e_time,
                                    @RequestParam String uid){
       return service.getBetInfo(s_time,e_time,uid);
    }


    /**
     * 封盘统计
     */
    @GetMapping("/getBetList")
    public List<BetInfoSticVo> getBetList(@RequestParam String bcid){
        return service.getBetList(bcid);
    }

    /**
     * 获取内容
     */
    @GetMapping("/getContent")
    public String getContent(){
        return service.getContent();
    }

    /**
     * 更新
     */
    @PostMapping("/updateContent")
    public String updateContent(@RequestParam String content){
       return service.updateContent(content);
    }
}
